/******************************************************************************
**                                                                           **
**                 Proprietary and Confidential Information                  **
**                                                                           **
**                 Copyright (c) Conexant Systems, Inc. Unpublished                  **
**                                                                           **
** This source code and the algorithms implemented therein constitute        **
** confidential information and may compromise trade secrets of Conexant Systems,    **
** Inc. or its associates, and any unauthorized use thereof is prohibited.   **
**                                                                           **
******************************************************************************/

#ifndef dc_imgbuf_api_h
#define dc_imgbuf_api_h

#include "dc_container_api.h"
#include "dc_image_api.h"


// DBGMON WIN32 note.
//
// This header file is used for dbgmon builds to provide prototypes for the 
// data container API functions (to support dbgmon side dbgext which allows
// host dlls to make "calls" to data container API functions).  
//
// To enable API functions to be callable within DBGMON user dlls, we need
// to include the appropriate dll export/import function qualifiers.  For 
// firmware, no function qualifier is used.
//

#ifndef WIN32
# define FUN_QUALIFIER
#else
# define FUN_QUALIFIER CPP DBGMON_API
#endif


#define DC_IMGBUF_PRODUCER DC_CIRCBUF_PRODUCER
#define DC_IMGBUF_CONSUMER DC_CIRCBUF_CONSUMER

typedef struct DC_IMGBUF_STRUCT
{
  // imgbuf is based on circbuf base container
  DC_CIRCBUF circbuf;
  
  // image attributes
  DC_IMAGE image_attributes;

} DC_IMGBUF;


// better matching names for alerts
#define DC_IMGBUF_ALERT_SCANLINE_THRESHOLD  DC_CONTAINER_ALERT_THRESHOLD
#define DC_IMGBUF_ALERT_PRODUCTION_COMPLETE DC_CONTAINER_ALERT_PRODUCTION_COMPLETE
#define DC_IMGBUF_ALERT_HEIGHT_SPECIFIED    DC_CONTAINER_ALERT_HEIGHT_SPECIFIED
#define DC_IMGBUF_ALERT_CONSUMPTION_COMPLETE DC_CONTAINER_ALERT_CONSUMPTION_COMPLETE

//
//
// IMGBUF container API
//
//

FUN_QUALIFIER DC_RETURN_CODE dc_imgbuf_create 
( DC_IMGBUF *imgbuf,
  char *name,
  DC_IMAGE_CHANNELS channels,
  DC_IMAGE_BITDEPTH bitdepth,
  DC_IMAGE_FORMAT format,
  void *base,
  UINT32 stride,
  UINT32 ySize,
  UINT32 yStart,
  UINT32 width,
  UINT32 height );

FUN_QUALIFIER DC_RETURN_CODE dc_imgbuf_info_get
( DC_IMGBUF *imgbuf,
  char **name,
  DC_IMAGE_CHANNELS *channels,
  DC_IMAGE_BITDEPTH *bitdepth,
  DC_IMAGE_FORMAT *format,
  void **base,
  UINT32 *stride,
  UINT32 *ySize,
  UINT32 *yStart,
  UINT32 *width,
  UINT32 *height );

FUN_QUALIFIER DC_RETURN_CODE dc_imgbuf_height_specify
( DC_IMGBUF *imgbuf,
  UINT32 height );

#define dc_imgbuf_overlap(a,b,c,d) \
        dc_circbuf_overlap(&(a)->circbuf, &(b)->circbuf, c, d)
      
//DC_RETURN_CODE dc__imgbuf_holdback_units_specify
//( DC_IMGBUF *imgbuf, UINT32 units);
#define dc__imgbuf_holdback_units_specify(a, b) \
        dc__circbuf_holdback_units_specify(&(a)->circbuf, b)

//DC_RETURN_CODE dc__imgbuf_holdback_units_release
//( DC_IMGBUF *imgbuf, UINT32 units);
#define dc__imgbuf_holdback_units_release(a, b) \
        dc__circbuf_holdback_units_release(&(a)->circbuf, b)
                
//DC_RETURN_CODE dc__imgbuf_holdback_units_get
//( DC_IMGBUF *imgbuf, UINT32 *units);
#define dc__imgbuf_holdback_units_get(a, b) \
        dc__circbuf_holdback_units_get(&(a)->circbuf, b)
                
//DC_RETURN_CODE dc_imgbuf_delete
//( DC_IMGBUF *imgbuf);
#define dc_imgbuf_delete(a) \
        dc_circbuf_delete(&(a)->circbuf)

//DC_RETURN_CODE dc_imgbuf_producer_setup
//( DC_IMGBUF_PRODUCER *producer,
//  char *name,
//  DC_CONTAINER_ALERT_FCN alertFcn,
//  UINT32 alertUserParam );
#define dc_imgbuf_producer_setup dc_circbuf_producer_setup

//DC_RETURN_CODE dc_imgbuf_producer_register
//( DC_IMGBUF *imgbuf,
//  DC_IMGBUF_PRODUCER *producer);
#define dc_imgbuf_producer_register(a,b) \
        dc_circbuf_producer_register(&(a)->circbuf,b)

// DC_RETURN_CODE dc_imgbuf_status_get
//( DC_IMGBUF *imgbuf,
//  UINT32 *production_state,
//  UINT32 *consumption_state,
//  UINT32 *reserved2, UINT32 *reserved3,
//  UINT32 *reserved4,UINT32 *reserved5, UINT32 *reserved6,
//  UINT32 *reserved7);
#define dc_imgbuf_status_get(a,b,r1,r2,r3,r4,r5,r6,r7) \
        dc_circbuf_status_get(&(a)->circbuf,b,r1,r2,r3,r4,r5,r6,r7)
#if 0
DC_RETURN_CODE dc_imgbuf_producer_alerts_set
( DC_IMGBUF_PRODUCER *producer,
  UINT32 alertMask,
  UINT32 scanlineThreshold );
#endif
#define dc_imgbuf_producer_alerts_set dc_circbuf_producer_alerts_set

#if 0
DC_RETURN_CODE dc_imgbuf_producer_empty_get 
( DC_IMGBUF_PRODUCER *producer,
  UINT32 *emptyScalines );
#endif
#define dc_imgbuf_producer_empty_get dc_circbuf_producer_empty_get
#define dc__imgbuf_producer_overlap_empty_get dc__circbuf_producer_overlap_empty_get

#if 0
DC_RETURN_CODE dc_imgbuf_producer_yValue_get 
( DC_IMGBUF_PRODUCER *producer,
  UINT32 *yValue );
#endif
#define dc_imgbuf_producer_yValue_get dc_circbuf_producer_yValue_get

#if 0
DC_RETURN_CODE dc_imgbuf_producer_produce
( DC_IMGBUF_PRODUCER *producer,
  UINT32 scanlines );
#endif
#define dc_imgbuf_producer_produce dc_circbuf_producer_produce

//DC_RETURN_CODE dc_imgbuf_producer_unregister
//( DC_IMGBUF_PRODUCER *producer );
#define dc_imgbuf_producer_unregister dc_circbuf_producer_unregister

//DC_RETURN_CODE dc_imgbuf_consumer_setup
//( DC_IMGBUF_CONSUMER *consumer,
//  char *name,
//  DC_CONTAINER_ALERT_FCN alertFcn,
//  UINT32 alertUserParam);
#define dc_imgbuf_consumer_setup dc_circbuf_consumer_setup

//DC_RETURN_CODE dc_imgbuf_consumer_register 
//( DC_IMGBUF *imgbuf,
//  DC_IMGBUF_CONSUMER *consumer );
#define dc_imgbuf_consumer_register(a,b) \
        dc_circbuf_consumer_register(&(a)->circbuf,b)

#if 0
DC_RETURN_CODE dc_imgbuf_consumer_alerts_set
( DC_IMGBUF_CONSUMER *consumer,
  UINT32 alertMask,
  UINT32 scanlineThreshold );
#endif
#define dc_imgbuf_consumer_alerts_set dc_circbuf_consumer_alerts_set

#if 0
DC_RETURN_CODE dc_imgbuf_consumer_valid_get 
( DC_IMGBUF_CONSUMER *consumer,
  UINT32 *validScalines );
#endif
#define dc_imgbuf_consumer_valid_get dc_circbuf_consumer_valid_get

#if 0
DC_RETURN_CODE dc_imgbuf_consumer_yValue_get 
( DC_IMGBUF_CONSUMER *consumer,
  UINT32 *yValue );
#endif
#define dc_imgbuf_consumer_yValue_get dc_circbuf_consumer_yValue_get

#if 0
DC_RETURN_CODE dc_imgbuf_consumer_consume
( DC_IMGBUF_CONSUMER *consumer,
  UINT32 scanlines );
#endif
#define dc_imgbuf_consumer_consume dc_circbuf_consumer_consume

//DC_RETURN_CODE dc_imgbuf_consumer_unregister
//( DC_IMGBUF_CONSUMER *consumer);
#define dc_imgbuf_consumer_unregister dc_circbuf_consumer_unregister


//DC_RETURN_CODE dc_imgbuf_monitor_on
//( DC_CONTAINER_DEBUG_HANDLE handle );
#define dc_imgbuf_monitor_on dc_circbuf_monitor_on

#if 0
DC_RETURN_CODE dc_imgbuf_monitor_available_get 
( DC_CONTAINER_DEBUG_HANDLE handle,
  UINT32 *availableScalines );
#endif
#define dc_imgbuf_monitor_available_get dc_circbuf_monitor_available_get

#if 0
DC_RETURN_CODE dc_imgbuf_monitor_yValue_get 
( DC_CONTAINER_DEBUG_HANDLE handle,
  UINT32 *yValue );
#endif
#define dc_imgbuf_monitor_yValue_get dc_circbuf_monitor_yValue_get

#if 0
DC_RETURN_CODE dc_imgbuf_monitor_monitor
( DC_CONTAINER_DEBUG_HANDLE handle,
  UINT32 scanlines );
#endif
#define dc_imgbuf_monitor_monitor dc_circbuf_monitor_monitor

//DC_RETURN_CODE dc_imgbuf_monitor_off
//( DC_CONTAINER_DEBUG_HANDLE handle );
#define dc_imgbuf_monitor_off dc_circbuf_monitor_off



FUN_QUALIFIER DC_RETURN_CODE dc_imgbuf_debug_info_get
( DC_CONTAINER_DEBUG_HANDLE handle,
  char **name,
  DC_IMAGE_CHANNELS *channels,
  DC_IMAGE_BITDEPTH *bitdepth,
  DC_IMAGE_FORMAT *format,
  void **base,
  UINT32 *stride,
  UINT32 *ySize,
  UINT32 *yStart,
  UINT32 *width,
  UINT32 *height,
  UINT32 *monitorEnabled,
  UINT32 *producerCumulativeScanlines,
  UINT32 *consumerCumulativeScanlines );





#undef FUN_QUALIFIER

#endif // dc_imgbuf_api_h
